﻿using Autofac;
using Microsoft.EntityFrameworkCore;
using SSPivot.AspNetCore.Repository; 
using SSPivot.Data.MultiTenancy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSPivot.AspNetCore.DependencyInjection
{
    public class SSPivotAspNetCoreModule : Module
    {
        //    // Autofac配置（可选）
        //    builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory())
        //.ConfigureContainer<ContainerBuilder>(containerBuilder =>
        //{
        //    containerBuilder.RegisterModule<AutofacModule>();
        //});

        protected override void Load(ContainerBuilder builder)
        { 
            builder.RegisterType<UnitOfWork>().As<IUnitOfWork>().InstancePerLifetimeScope();
            builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope(); 

        }
    }
}
